from fastapi import APIRouter, Depends
from fastapi_pagination import Page
from app.api.admin.schema.order.order import OrderListInSchema, OrderOutSchema
from app.api.admin.service.order.order import OrderService
from app.common.schema import PageInationResult
from app.utils.res import unified_resp


order = APIRouter(prefix="/order", tags=["订单"])


@order.post("/list", response_model=PageInationResult[OrderOutSchema])
@unified_resp
async def list(list_in: OrderListInSchema, order_service: OrderService = Depends(OrderService.instance)):

    return await order_service.list(list_in)


@order.post("/cancle/{order_id}")
@unified_resp
async def cancle(order_id: str, order_service: OrderService = Depends(OrderService.instance)):
    print("order_id", order_id)
    return await order_service.cancel(order_id)


@order.post("/detail")
@unified_resp
async def detail(order_id: str, order_service: OrderService = Depends(OrderService.instance)):
    return await order_service.detail(order_id)
